import request from '/@/utils/request';
import { useUrlUtil } from '/@/utils/urlUtil';
import { BaseRequest, BaseResponse } from '/@/interfaces/BaseModel';
import { TaskGroupInfoApi } from '/@/enums/dpp-api-enum';
import {
    TaskGroupInfoSearchParamModel,
    TaskGroupInfoListModel,
    TaskGroupInfoDetailModel,
    TaskGroupInfoAddParamModel,
    TaskGroupInfoEditParamModel,
    TaskGroupInfoDeleteParamModel
} from '/@/interfaces/DataPipelineModel';

function useTaskGroupInfo() {
    return {
        list: function (payload: BaseRequest<TaskGroupInfoSearchParamModel>) {
            return request.post<BaseResponse<TaskGroupInfoListModel[]>>(TaskGroupInfoApi.LIST, payload);
        },
        detail: function (payload: Object) {
            const useUrl = useUrlUtil();
            return request.get<BaseResponse<TaskGroupInfoDetailModel>>(useUrl.joinParam(TaskGroupInfoApi.DETAIL, payload));
        },
        add: function (payload: BaseRequest<TaskGroupInfoAddParamModel>) {
            return request.post<BaseResponse<boolean>>(TaskGroupInfoApi.ADD, payload);
        },
        edit: function (payload: BaseRequest<TaskGroupInfoEditParamModel>) {
            return request.post<BaseResponse<boolean>>(TaskGroupInfoApi.EDIT, payload);
        },
        triggerEnable: function (payload: Object) {
            const useUrl = useUrlUtil();
            return request.get<BaseResponse<Boolean>>(useUrl.joinParam(TaskGroupInfoApi.TRIGGER_ENABLE, payload));
        },
        startOnce: function (payload: Object) {
            const useUrl = useUrlUtil();
            return request.get<BaseResponse<Boolean>>(useUrl.joinParam(TaskGroupInfoApi.START_ONCE, payload));
        },
        del: function (payload: BaseRequest<TaskGroupInfoDeleteParamModel>) {
            return request.post<BaseResponse<boolean>>(TaskGroupInfoApi.DEL, payload);
        },
    };
}

export default useTaskGroupInfo;